<?php
declare (strict_types = 1);

namespace app\middleware;

class Response
{
    public function handle($request, \Closure $next)
    {
        $response = $next($request);
        if ($response->getCode() === 200) {
            return json()->data([
                'code' => 0,
                'msg' => 'success',
                'data' =>  $response->getData()
            ]);
        } elseif ($response->getCode() === 500) {
            return json()->data($response->getData());
        } else {
            return $response;
        }

    }
}
